using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.Collections;

namespace YanHongCrawler
{
    public partial class Form1 : Form
    {
        private delegate void MyDelegate();
        public Form1()
        {
            InitializeComponent();
        }

        private void searchButton_Click(object sender, EventArgs e)
        {
            string keyword = searchTextBox.Text;
            Parallel.Invoke(new Action[] {
                ()=>editBox1(keyword),
                ()=>editBox2(keyword)
            });

        }
        private void editBox1(string keyWord)
        {
            this.BeginInvoke(new MyDelegate(() => { resultTextbox1.Text = "正在并行爬取关键字：" + keyWord; }));
            SearchController sc1 = new SearchController();
            this.BeginInvoke(new MyDelegate(() => { resultTextbox1.Text = sc1.Download(keyWord); }));

        }

        private void editBox2(string keyWord)
        {
            this.BeginInvoke(new MyDelegate(() => { resultTextBox2.Text = "正在并行爬取关键字：" + keyWord; }));
            SearchController sc2 = new SearchController();
            this.BeginInvoke(new MyDelegate(() => { resultTextBox2.Text = sc2.Download(keyWord); }));
        }

}
}